/**
 * 计分面板
 */
export default class ScorePanel{
    score:number;
    level:number;
    upScore:number;
    maxLevel:number;

    scoreElement:HTMLElement;
    levelElement:HTMLElement;

    constructor(maxLevel :number = 10,upScore:number = 10){
        this.score = 0;
        this.level = 1;
        this.upScore = upScore;
        this.maxLevel = maxLevel;

        this.scoreElement = document.querySelector('#score')!;
        this.levelElement = document.querySelector('#level')!;
    }

    addCore(){
        this.scoreElement.innerHTML=++this.score+"";//innerText 部分浏览器不支持，使用innerHtml
        if(this.score % this.upScore == 0){
            this.levelUp();
        }
    }

    levelUp(){
        this.levelElement.innerHTML=++this.level+"";
    }

}